<template>
    <el-drawer
        v-model="isShow"
        title="预案详情"
        :destroy-on-close="true"
        size="50%"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
        :show-close="false"
    >
        <el-descriptions :column="2" :border="true">
            <el-descriptions-item label="预案编号：">{{ detail.plancode }}</el-descriptions-item>
            <el-descriptions-item label="编制部门：">{{ detail.depName }}</el-descriptions-item>
            <el-descriptions-item label="预案名称：">{{ detail.planname }}</el-descriptions-item>
            <el-descriptions-item label="预案类型：">
                <dict-tag :options="nj_yuan_type" :value="detail.plantype"/>
            </el-descriptions-item>
            <el-descriptions-item label="适用范围：" :span="2">{{ detail.scope }}</el-descriptions-item>

            <template v-if="isPersonality">
                <el-descriptions-item label="重点对象：" :span="2">{{ detail.peopleName }}</el-descriptions-item>
                <el-descriptions-item label="人员基本情况：" :span="2">{{ detail.peopleinfo }}</el-descriptions-item>
                <el-descriptions-item label="简要案情：" :span="2">{{ detail.caseinfo }}</el-descriptions-item>
                <el-descriptions-item label="信访诉求：" :span="2">{{ detail.appeal }}</el-descriptions-item>
                <el-descriptions-item label="信访过程：" :span="2">{{ detail.process }}</el-descriptions-item>
                <el-descriptions-item label="检察机关办理结果：" :span="2">{{ detail.result }}</el-descriptions-item>
                <el-descriptions-item label="答复口径：" :span="2">{{ detail.reply }}</el-descriptions-item>
                <el-descriptions-item label="以往表现：" :span="2">{{ detail.performance }}</el-descriptions-item>
            </template>
            <el-descriptions-item label="应急处置人员和职责：" :span="2">{{ detail.duty }}</el-descriptions-item>
            <el-descriptions-item label="应急处置程序和措施：" :span="2">{{ detail.measure }}</el-descriptions-item>
            <el-descriptions-item label="风险等级评估低：">
                <dict-tag :options="nj_fengxian_level" :value="detail.risklevel"/>
            </el-descriptions-item>
            <el-descriptions-item label="是否使用警械具：">
                <dict-tag :options="sys_yes_no" :value="detail.useequipment"/>
            </el-descriptions-item>
            <el-descriptions-item label="编制单位：">{{detail.unitname}}</el-descriptions-item>
            <el-descriptions-item label="修订日期：">{{detail.adddate}}</el-descriptions-item>
            <el-descriptions-item label="录入人员：">{{ detail.addUserName}}</el-descriptions-item>
            <el-descriptions-item label="录入时间：">{{ detail.adddate }}</el-descriptions-item>
            <el-descriptions-item label="部门审核领导：">{{ detail.depLeaderName }}</el-descriptions-item>
            <el-descriptions-item label="分管审核领导：">{{ detail.unitLeaderName }}</el-descriptions-item>
            <el-descriptions-item label="部门领导审核意见：" :span="2">{{ detail.depleadernote }}</el-descriptions-item>
            <el-descriptions-item label="分管领导审核意见：" :span="2">{{ detail.unitleadernote }}</el-descriptions-item>
        </el-descriptions>


        <template #footer>
            <!-- 取消 -->
            <el-button @click="changeShowStatus">关闭</el-button>
        </template>
    </el-drawer>
</template>

<script setup>
import {getPlanInfo} from "@/api/PlanManage/Plan.js";
import {PlanTypeEnum} from "@/enum/PlanEnum.js";

const {proxy} = getCurrentInstance()
const {nj_yuan_type, nj_fengxian_level, sys_yes_no} = proxy.useDict('nj_yuan_type', 'nj_fengxian_level', 'sys_yes_no')

const isShow = ref(false)
// 预案类型变更是否个性
const isPersonality = ref(false)
// 详情内容
const detail = ref({})

// 变更显示状态
const changeShowStatus = () => {
    isShow.value = !isShow.value
}

// 展示抽屉详情
const showDetail = async (data) => {
    changeShowStatus()
    await getDetail(data.planId)
}

defineExpose({showDetail})

// 预案类型变更 · 控制相关板块显示
const changePlanTypeHandle = (type) => {
    isPersonality.value = type === PlanTypeEnum.INDIVIDUAL
}

// 获取详情
const getDetail = async (id) => {
    const res = await getPlanInfo(id)
    detail.value = {
        ...detail.value,
        ...res.data
    }
    changePlanTypeHandle(res.data.plantype);
}

</script>

<style scoped lang="scss">

</style>